<%#
  # WebROaR - Ruby Application Server - http://webroar.in/
  # Copyright (C) 2009  Goonj LLC
  #
  # This file is part of WebROaR.
  #
  # WebROaR is free software: you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # WebROaR is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with WebROaR.  If not, see <http://www.gnu.org/licenses/>.
  #%>

<% if File.exist?(MAIL_FILE_PATH) and info = YAML::load_file(MAIL_FILE_PATH) %>
	<% if info['smtp'] %>
		<table width = 95% align='center'>
		    <tr>
		        <th  width = 50% colspan = 2>
		            <b>Mail Settings :- SMTP</b>&nbsp;&nbsp;&nbsp;<%=link_to_function('Help', :onclick => 'addHelp("mail",event);') %>
		        </th>
		        <th width = 50% colspan = 2 align = 'right'>
		            <%=link_to_remote 'Sendmail', :update => 'mail_div', :url =>  {:controller => 'mail_specification', :action => 'sendmail_form'} %>&nbsp;&nbsp;&nbsp;
		            <%=link_to_remote 'Edit', :update => 'mail_div', :url => {:controller => 'mail_specification', :action => 'edit_smtp', :smtp => info['smtp']} %>&nbsp;&nbsp;&nbsp;
								<% if info['email_notification'] and info['email_notification'].downcase == 'disabled' %>
		              <%=link_to_remote 'Enable', :update => 'mail_div', :url => {:controller => 'mail_specification', :action => 'enable_notification'}, :confirm => ENABLE_EMAIL_NOTIFICATION, :oncontextmenu => 'return false;' %>
								<% elsif info['email_notification'] and info['email_notification'].downcase == 'enabled' %>
								  <%=link_to_remote 'Disable', :update => 'mail_div', :url => {:controller => 'mail_specification', :action => 'disable_notification'}, :confirm => DISABLE_EMAIL_NOTIFICATION, :oncontextmenu => 'return false;' %>
								<% end %>	
		        </th>
		    </tr>
		    <tr>
		        <td  width = 25%>
		            Server
		        </td>
		        <td  width = 25%>
		            <%=info['smtp']['address'] %>
		        </td>
		        <td  width = 25%>
		            Port
		        </td>
		        <td  width = 25%>
		            <%=info['smtp']['port'] %>
		        </td>
		    </tr>
		    <tr>
		        <td >
		            Domain
		        </td>
		        <td >
		            <%=info['smtp']['domain'] %>
		        </td>
		        <td >
		            Authentication
		        </td>
		        <td >
		            <%=info['smtp']['authentication'] %>
		        </td>
		    </tr>
		    <tr>
		        <td >
		            User Name
		        </td>
		        <td >
		            <%=info['smtp']['user_name'] %>
		        </td>
		        <td >
		            Password
		        </td>
		        <td >
		            **************
		        </td>
		    </tr>
		    <tr>
		        <td >
		            Sender's Email Address
		        </td>
		        <td >
		            <%=info['smtp']['from'] %>
		        </td>
		        <td >
		            Recipient Email Addresses
		        </td>
		        <td >
		            <%=info['smtp']['recipients'] %>
		        </td>
		    </tr>
		    <tr>
		    </tr>
		</table>
		<br/>
		<br/>
	<% elsif info['sendmail'] %>
		<table width = 95% align='center'>
		    <tr>
		        <th width = 50%>
		            <b>Mail Settings :- Sendmail</b>&nbsp;&nbsp;&nbsp;<%=link_to_function('Help', :onclick => 'addHelp("mail",event);') %>
		        </th>
		        <th width = 50% colspan = 2 align = 'right'>
		            <%=link_to_remote 'SMTP', :update => 'mail_div', :url => {:controller => 'mail_specification', :action => 'smtp_form'} %>&nbsp;&nbsp;&nbsp;
		            <%=link_to_remote 'Edit', :update => 'mail_div', :url => {:controller => 'mail_specification', :action => 'edit_sendmail', :sendmail => info['sendmail']} %>&nbsp;&nbsp;&nbsp;
		            <% if info['email_notification'] and info['email_notification'].downcase == 'disabled' %>
                  <%=link_to_remote 'Enable', :update => 'mail_div', :url => {:controller => 'mail_specification', :action => 'enable_notification'}, :confirm => ENABLE_EMAIL_NOTIFICATION, :oncontextmenu => 'return false;' %>
                <% elsif info['email_notification'] and info['email_notification'].downcase == 'enabled' %>
                  <%=link_to_remote 'Disable', :update => 'mail_div', :url => {:controller => 'mail_specification', :action => 'disable_notification'}, :confirm => DISABLE_EMAIL_NOTIFICATION, :oncontextmenu => 'return false;' %>
                <% end %> 
		        </th>
		    </tr>
		    <tr>
		        <td  width = 50%>
		            Location
		        </td>
		        <td colspan = 2 width = 50%>
		            <%=info['sendmail']['location']%>
		        </td>
		    </tr>
		    <tr>
		        <td >
		            Sender's Email Address
		        </td>
		        <td colspan = 2 >
		            <%=info['sendmail']['from'] %>
		        </td>
		    </tr>
		    <tr>
		        <td >
		            Recipient Email Addresses
		        </td>
		        <td colspan = 2 >
		            <%=info['sendmail']['recipients'] %>
		        </td>
		    </tr>
		</table>
		<br/>
		<br/>
	<% end %>
<% else %>
	<table width = 95% align='center'>
	    <tr>
	        <th width = 80%>
	            <b>Mail Settings</b>&nbsp;&nbsp;&nbsp;<%=link_to_function('Help', :onclick => 'addHelp("mail",event);') %>
	        </th>
	        <th width = 10%>
	            <%=link_to_remote 'SMTP', :update => 'mail_div', :url => {:controller => 'mail_specification', :action => 'smtp_form'} %>
	        </th>
	        <th width = 10%>
	            <%=link_to_remote 'Sendmail', :update => 'mail_div', :url => {:controller => 'mail_specification', :action => 'sendmail_form'} %>
	        </th>
	    </tr>
	</table>
	<br/>
	<br/>
<% end %>
